home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 22.8 KB | 1,024 lines | [TEXT/ToyS] |
- (*
- V1.42 ◊ This script is © 1998-1999 by AKUA interactive media AG.
-
- See the included documentation for more information.
-
- V142/26Feb99/Catch more -911 errors and show better info when it happens
- V140/01Feb99/Fix up some prefs stuff
- V130/22Jan99/Handle return of printer config
- V121/07Jan99/Server Registration routine modified
- V120/06Jan99/Support prefs feedback from server
- V110/05Jan99/Redid a lot of routines, fixed a lot of bugs
- V102/25Jul98/Work on timing problems causing 040 crash in AppleScript
- V101/11Jul98/More error checking when talking to server
- *)
-
- -- User setable properties
- property kasAllowAlerts : true -- Set to false to stop any alerts from appearing
- property kpsTitle : "PowerSPrint Client"
- property kpsVersion : "V1.42"
- property kpsTitleW : kpsTitle & " " & kpsVersion
- property kpfPrefName : kpsTitle & " V1.3"
- property kcnTimeOut : 300 -- Kill operations if not touched in this many seconds
- property kcnChunkSize : 25000 -- How many bytes per chunk?
-
- property kcnDefUser : "CasaVision"
- property kcnDefPass : ""
- property kcnUseDef : false -- Set to true to use the above info always
-
- -- Internal Properties
- property kasFinder : "Finder" -- The Finder
- property kasAssumedIdentity : false -- Are we ourselves?
- property kcnSetupAsk : true -- Ask once about transfer of settings?
- property kasServerName : "PowerSPrint Server"
-
- -- Internal Globals
- global gpsStatus -- Window with status info
- global gpsStatLoc -- Location of status window
- global gpsSpool -- Spool folder
- global gpsSpoolTypes -- Types of spool files
- global gpsConnected -- Connected to server?
- global gpsMonCre -- Creator of our PrintMonitor
-
- global gcnUser -- User to log into server with
- global gcnPass -- Password to log into server with
- global gcnLink -- True if we've gotten user/pass
-
- global gcnServer -- Alias of PowerSPrint Server
- global gcnServProc -- Name of server app
- global gcnServMach -- Name of server machine
- global gcnServZone -- Name of server zone
-
- global gasReady -- Are we ready?
-
-
- on run
- init()
- return false
- end run
-
-
- on init()
- -- Don't have a status window yet?
- if ((the open windows) is {}) then
- set gasReady to false
- set gpsConnected to false
- set gcnLink to false
- set gpsStatus to 0
- pfLoad()
- StatusNew()
-
- -- Must be front process for trap patching to work?!?
- talk as user kcnDefUser ¬
- with password kcnDefPass
- end if
-
- set gasReady to spSetup()
- end init
-
-
- on idle
- init()
-
- if (not gasReady) then
- ShowState("Waiting for you…")
- return 3
- end if
-
- StatusUpdate()
-
- if (spCount() > 0) then
- ShowState("Working…")
- CopyAll()
- StatusUpdate()
- ShowState("Idle.")
- return 15
- end if
-
- repeat with n from 10 to 1 by -1
- ShowState("Quitting… - you can reposition this window now (" & n & ")")
- pause for 60
- end repeat
- quit
- end idle
-
-
- on quit
- set gasReady to false
- try
- StatusUpdate()
- pfSave()
- StatusDel()
- on error
- beep
- end try
- continue quit
- end quit
-
-
- on open fsObjs
- init()
- spSetup()
-
- repeat with fsObj in fsObjs
- set fInfo to basic info for fsObj
-
- if (catalog kind of fInfo) is a folder then
- spSet(fsObj)
- else if (system type of fInfo) is "APPL" then
- if (system creator of fInfo is "dplt") then
- cnServerSet(fsObj)
- else
- pmSet(fsObj)
- end if
- else if not gasReady then
- display dialog "Please set me up first!" buttons {"Yo!"} default button 1
- else
- CopyOne(0, fsObj)
- end if
- end repeat
-
- spSetup()
- end open
-
-
- on pfLoad()
- try
- set prefs to load preference named kpfPrefName
- on error err number errNum
- set prefs to ¬
- {PfStatLoc:{40, 60} ¬
- , PfServer:0 ¬
- , PfSpool:path to printmonitor ¬
- , PfSpoolTypes:{} ¬
- , PfMonCre:("????") ¬
- , PfServProc:("") ¬
- , PfServMach:("") ¬
- , PfServZone:("") ¬
- }
- end try
-
- -- Globals from prefs
- set gpsStatLoc to PfStatLoc of prefs
- set gcnServer to PfServer of prefs
- set gpsSpool to PfSpool of prefs
- set gpsSpoolTypes to PfSpoolTypes of prefs
- set gpsMonCre to PfMonCre of prefs
- set gcnServProc to PfServProc of prefs
- set gcnServMach to PfServMach of prefs
- set gcnServZone to PfServZone of prefs
-
- -- Validate Spool Folder
- try
- set x to resolve chain gpsSpool
- on error
- set gpsSpool to path to printmonitor
- end try
- end pfLoad
-
-
- on pfSave()
- if (gpsStatus is not 0) then
- set newLoc to screen location of ¬
- (display info gpsStatus message "Saving prefs…" at line 2) -- Action
- if (newLoc is not gpsStatLoc) then set gpsStatLoc to newLoc
- end if
-
- -- Appending {} to the end of this causes crashes in System 7.x
- set prefs to ¬
- {PfStatLoc:gpsStatLoc ¬
- , PfServer:gcnServer ¬
- , PfSpool:gpsSpool ¬
- , PfSpoolTypes:gpsSpoolTypes ¬
- , PfMonCre:gpsMonCre ¬
- , PfServProc:gcnServProc ¬
- , PfServMach:gcnServMach ¬
- , PfServZone:gcnServZone ¬
- }
-
- save preference prefs named kpfPrefName
- ShowAction("Saved.")
- end pfSave
-
-
- on pmSet(fsObj)
- ShowAction("Setting Monitor…")
-
- set fInfo to basic info for fsObj
- set fic to the icon for fsObj
- collate fsObj with the trasher
-
- set myAlias to path to me
-
- set the catalog info of myAlias to fInfo
- set the icon of myAlias to fic
- collate myAlias renaming it to (catalog name of fInfo)
-
- set gpsMonCre to (system creator of fInfo)
- set kasAssumedIdentity to true
- pfSave()
- end pmSet
-
-
- on spSet(fsObj)
- set gpsSpool to fsObj
- pfSave()
- end spSet
-
-
- on spCount()
- if (gpsSpoolTypes is {} and gpsMonCre is "????") then return 0
- return the number of items in ¬
- (the entries in gpsSpool whose creators are in {gpsMonCre})
- end spCount
-
-
- on spCheckLamers()
- set orphs to (the entries in gpsSpool whose types are in {"Part"})
- set daddy to (gpsSpool as string)
-
- repeat with orph in orphs
- try
- collate ((daddy & orph) as alias) with the deleter
- on error
- try
- collate ((daddy & orph) as alias) with the trasher
- on error
- ShowError("Couldn't remove spool file:" & orph)
- end try
- end try
- end repeat
- end spCheckLamers
-
-
- on StatusNew()
- set gpsStatus to ¬
- display info titled kpsTitleW ¬
- message ("Starting up…") ¬
- located at gpsStatLoc
- set gpsStatLoc to screen location of gpsStatus
- end StatusNew
-
-
- on StatusUpdate()
- if (gpsStatus is not 0) then
- set newLoc to screen location of ¬
- (display info gpsStatus ¬
- message ("Spooled Files: " & spCount()))
- if (newLoc is not gpsStatLoc) then
- set gpsStatLoc to newLoc
- pfSave()
- end if
- end if
- end StatusUpdate
-
-
- on ShowState(msg)
- if (gpsStatus is not 0) then ¬
- display info gpsStatus ¬
- message msg
- end ShowState
-
-
- on Status(msg)
- if (gpsStatus is not 0) then
- display info gpsStatus ¬
- message msg ¬
- at line 2
- end if
- end Status
-
-
- on ShowAction(msg)
- display info gpsStatus ¬
- message msg ¬
- at line 3 ¬
- using color 16
- end ShowAction
-
-
- on ShowReady()
- display info gpsStatus ¬
- message ("Ready.") ¬
- at line 3 ¬
- using color (16 * 32)
- end ShowReady
-
-
- on ShowError(msg)
- if (gpsStatus is not 0) then
- display info gpsStatus ¬
- message msg ¬
- at line 3 ¬
- using color (12 * 1024)
- end if
- set gpsConnected to false
- pause for 300
- return
- end ShowError
-
-
- on StatusDel()
- display info gpsStatus with disposal
- set gpsStatus to 0
- end StatusDel
-
-
- on spSetup()
- if gasReady then return true
-
- if (gpsStatus is not 0) then
- display info gpsStatus ¬
- message ("Spool: " & (gpsSpool as string)) ¬
- at line 9 ¬
- using color 16
-
- if (option key down of (input state)) then cnServerChoose()
-
- if (gcnServer is 0) then
- display info gpsStatus ¬
- message ("WAITING FOR THE SERVER TO BE DROPPED ON ME") ¬
- at line 3 ¬
- using color (16 * 1024)
- display info gpsStatus ¬
- message ("(… or hold the option key down to choose a server)") ¬
- at line 4 ¬
- using color (16 * 1024)
- return false
- end if
-
- display info gpsStatus ¬
- message ("Server: " & gcnServZone & ":" & gcnServMach) ¬
- at line 11 ¬
- using color 16 + (16 * 32)
-
- if (control key down of (input state)) then
- try
- open {choose file with prompt "Choose the Print Monitor" of type {"APPL"}}
- on error
- beep
- end try
- end if
-
- if (shift key down of (input state)) then
- try
- open {choose folder with prompt "Choose Spool Folder (e.g. Spool Folder5)"}
- on error
- beep
- end try
- end if
-
- if (not kasAssumedIdentity) then
- display info gpsStatus ¬
- message ("WAITING FOR THE \"PRINT MONITOR\" APPLICATION TO BE DROPPED ON ME") ¬
- at line 3 ¬
- using color (16 * 1024)
- display info gpsStatus ¬
- message ("… or choose a different Spool folder by holding Shift") ¬
- at line 4 ¬
- using color (16 * 1024)
- display info gpsStatus ¬
- message ("… or choose the Monitor application by holding Control") ¬
- at line 5 ¬
- using color (16 * 1024)
- return false
- end if
-
- CopyAll() -- Try to do current spool files
-
- if (gpsSpoolTypes is {}) then
- display info gpsStatus ¬
- message ("WAITING TO PROCESS THE FIRST SPOOL FILE(s)") ¬
- at line 3 ¬
- using color (16 * 1024)
- display info gpsStatus ¬
- message ("… or choose a different Spool folder by holding Shift") ¬
- at line 4 ¬
- using color (16 * 1024)
- display info gpsStatus ¬
- message ("…") ¬
- at line 5 ¬
- using color 15
- return false
- end if
-
- display info gpsStatus ¬
- message ("…") ¬
- at line 4 ¬
- using color 15
- display info gpsStatus ¬
- message ("…") ¬
- at line 5 ¬
- using color 15
- end if
-
- ShowReady()
-
- return true
- end spSetup
-
-
- on ServerReg()
- talk as user gcnUser ¬
- with password gcnPass ¬
- on server gcnServMach ¬
- in AppleTalk zone gcnServZone
-
- ShowAction("Checking if server is ready…")
- pause for 2 with seconds timing --?!?
-
- try
- activate
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone to CheckReady()
- set ready to the result
- set gpsConnected to true
- on error errStr number errNum
- ShowError(errStr)
- set ready to false
- set gpsConnected to false
- end try
-
- if (not ready) then return false
-
- ShowAction("Registering…")
-
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to ClientReg()
- set servInfo to the result
-
- -- Check version
- if (SrvrVersion of servInfo) is not kpsVersion then
- display dialog ("WARNING" & return & ¬
- "Server is version " & (SrvrVersion of servInfo) & return & ¬
- "Client is version " & kpsVersion & return & return & ¬
- "This may not work.") buttons {"Uh-Oh"} default button 1
- end if
-
- -- Check printer setup
- ShowAction("Hold control to reset driver setup…")
- if (kcnSetupAsk or (control key down of (input state))) then
- set kcnSetupAsk to false
- if (button returned of (display dialog ("Do you wish to use copy the server's" & ¬
- " page setup and other settings to this client?" & ¬
- return & return & ¬
- "This may be helpful when one of the Macs" & ¬
- " uses a USB and the other a serial connection.") ¬
- buttons {"No", "Yes"} default button 1) is "Yes") then
- ShowAction("Applying server's driver setup…")
- copy SrvrSetup of servInfo to pc
- try
- set drvr to ¬
- (((path to extensions folder) as string) & ¬
- (print driver name of pc)) as alias
- set print driver alias of pc to (resolve chain drvr)
- ShowAction("Applied…")
- on error errStr number errNum
- ShowAction("Failed…")
- ShowError(errStr)
- end try
- printer configuration pc
- ShowAction("Saved…")
- end if
- end if
-
- -- Check prefs updates
- ShowAction("Scanning driver prefs…")
-
- try
- set epf to (((path to preferences folder) as string) & "Epson Preferences") as alias
- on error
- ShowAction("…")
- return true
- end try
-
- set pffs to SrvrDrvrPrefs of servInfo
- repeat with pff in pffs
- set pname to catalog name of pff
-
- try
- set pfile to ((epf as string) & pname) as alias
- set pinfo to basic info for pfile
- if (catalog modification date of pinfo) ¬
- is not (catalog modification date of pff) then ¬
- dvRequestFile(epf, pff)
- on error
- dvRequestFile(epf, pff)
- end try
- end repeat
-
- return true
- end ServerReg
-
-
- on dvRequestFile(destF, binf)
- ShowAction("Updating driver pref: " & (catalog name of binf))
-
- set pfile to ((destF as string) & (catalog name of binf))
-
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to dvReturnFile(binf)
- set fks to the result
-
- if ((item 1 of fks) is not 0) then -- data fork
- write data to the data fork of pfile from buffer (item 1 of fks)
- end if
-
- if ((item 2 of fks) is not 0) then -- resource fork
- set fk to ¬
- open fork from pfile ¬
- of type (system type of binf) ¬
- of creator (system creator of binf) ¬
- with resource fork and write access
- write data to fk from buffer (item 2 of fks)
- close fork fk
- end if
-
- set the catalog info of pfile to binf
- end dvRequestFile
-
-
- on cnServerSet(fsObj)
- set aInfo to alias info from fsObj
- set gcnServer to fsObj
- set gcnServProc to original name of aInfo
- set gcnServMach to alias server of aInfo
- set gcnServZone to alias zone of aInfo
- end cnServerSet
-
-
- on cnServerChoose()
- try
- set myServ to the server processes with prompt ("PowerSPrint: Choose a Server") ¬
- application label ("PowerSPrint Server") named kasServerName ¬
-
- on error
- beep
- return
- end try
-
- set myServ to item 1 of myServ
- set myApp to proc name of myServ
- set gcnServMach to proc mac of myServ
- set gcnServZone to proc zone of myServ
-
- cnGetLoginUser()
- if (not gcnLink) then return
-
- talk as user gcnUser ¬
- with password gcnPass ¬
- on server gcnServMach ¬
- in AppleTalk zone gcnServZone
-
- try
- tell application myApp of machine gcnServMach of zone gcnServZone to ¬
- ClientReg()
- set myRec to the result
- on error errStr
- ShowError(errStr)
- beep
- return
- end try
-
- if (SrvrVersion of myRec) is not kpsVersion then
- display dialog ("The chosen Server is not the same version as this client." & return & ¬
- return & "Please install the same version.") ¬
- buttons {"Damn"} default button 1
- beep
- return
- end if
-
- cnServerSet(SrvrApp of myRec)
- spSetup()
- end cnServerChoose
-
-
- on cnServerLaunch()
- cnGetLoginUser()
-
- if (not gcnLink) then return false
-
- talk as user gcnUser ¬
- with password gcnPass ¬
- on server gcnServMach ¬
- in AppleTalk zone gcnServZone
-
- ShowAction("Checking server status…")
-
- set servs to the server processes on server gcnServMach ¬
- in AppleTalk zone gcnServZone
-
- if (servs does not contain gcnServProc) then
- if (servs is {}) then
- ShowError("Server is down!")
- return false
- else
- ShowAction("Launching Server…")
- set gpsConnected to false
- -- Temporary fix until we update "talk as user" to handle background linking
- activate
- try
- tell application kasFinder ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to open gcnServer
-
- ShowAction("Waiting for server…")
- if not AwaitLaunch(gcnServZone, gcnServMach, gcnServProc) then return false
- -- If this is too low, the server crashes on a Quadra 700... AppleScript fault
- repeat with i from 60 to 1 by -1
- ShowAction("Server launched, waiting: " & i)
- pause for 59
- end repeat
- ShowAction("Contacting Server…")
- return false
- on error errStr number errNum
- ShowAction("Can't launch server")
- ShowError(errStr)
- if errNum is in {-927, -911} then -- No Auth or unrecog user
- ShowError("Hold Shift to re-enter user/password")
- pause for 120
- if (shift key down of (input state)) then
- ShowError("… will retry with new user …")
- GetOneFriend(true)
- end if
- end if
- return false
- end try
- end if
- end if
-
- set ready to true
-
- if (not gpsConnected) then
- ShowAction("Pinging Server…")
-
- set ready to ServerReg()
-
- if ready then
- ShowAction("Server Ready…")
- else
- ShowAction("Waiting for server…")
- end if
- end if
-
- return ready
- end cnServerLaunch
-
-
- on CopyNew(listOfFilesInSpool)
- if (not cnServerLaunch()) then return -1
-
- set myName to (the network zone name) & ":" & (the network server)
-
- try
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyPrep(myName, listOfFilesInSpool)
- set batchNum to the result
- on error errStr
- ShowError(errStr)
- return -1
- end try
-
- return batchNum
- end CopyNew
-
-
- on CopyDel(batchNum, kids)
- try
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyDone(batchNum)
- set okToDelete to the result
- on error errStr
- ShowError(errStr)
- return
- end try
-
- ShowAction("Removing spool…")
-
- if (okToDelete) then
- repeat with kid in kids
- try
- collate (((gpsSpool as string) & kid) as alias) with the deleter
- on error
- collate (((gpsSpool as string) & kid) as alias) with the trasher
- end try
- end repeat
- end if
- end CopyDel
-
-
- on CopyAll()
- if (not cnServerLaunch()) then return
-
- ShowAction("Prepare batch…")
-
- set daddy to gpsSpool as string
- set kids to (the entries in gpsSpool whose creators are in {gpsMonCre})
-
- if (kids is not {}) then
- set batchNum to CopyNew(kids)
- if (batchNum < 0) then return
-
- ShowAction("Batch ID: " & batchNum)
-
- set erred to false
-
- repeat with kid in kids
- if (CopyOne(batchNum, (daddy & kid) as alias) is not 0) then
- set erred to true
- exit repeat
- end if
- end repeat
-
- if (not erred) then CopyDel(batchNum, kids)
- end if
-
- ShowReady()
- end CopyAll
-
-
- on CopyOne(batchNum, fsObj)
- if (not cnServerLaunch()) then return -1
-
- ShowAction("Prepare file…")
-
- set myInfo to basic info for fsObj
-
- if (gpsSpoolTypes does not contain (system type of myInfo)) then
- set gpsSpoolTypes to gpsSpoolTypes & (system type of myInfo)
- pfSave()
- end if
-
- ShowAction("Copying " & (catalog name of myInfo))
-
- set pg to ¬
- display progress titled ("PowerSPrint Copy") ¬
- located at {-1, -1} ¬
- subtitled (catalog name of myInfo) ¬
- maximum ((data fork length of myInfo) + (resource fork length of myInfo)) ¬
- labeled "Starting…"
-
- set myName to (the network zone name) & ":" & (the network server)
-
- try
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyBeg(myName, batchNum, myInfo)
- set fid to the result
- on error errStr
- ShowError(errStr)
- display progress pg with disposal
- return -2
- end try
-
- set fLast to 0
-
- repeat with fork from 1 to 2
- set isRsrc to (fork is 1)
-
- set cnt to data fork length of myInfo
- set lbl to "Data Fork"
-
- if isRsrc then
- set cnt to resource fork length of myInfo
- set lbl to "Resource Fork"
- end if
-
- Status("Copying " & lbl)
-
- if (cnt > 0) then
- display progress pg ¬
- labeled lbl
-
- try
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyFork(fid, isRsrc)
- set svErr to the result
- on error errStr
- ShowError(errStr)
- display progress pg with disposal
- return -3
- end try
-
- if (svErr is not 0) then
- beep
- ShowError("Server Error: " & svErr)
- display progress pg with disposal
- return -4
- end if
-
- set fRef to open fork from fsObj ¬
- resource fork isRsrc
-
- set fOff to 0
-
- repeat while fOff < cnt
- set toRead to kcnChunkSize
- if (fOff + toRead) > cnt then ¬
- set toRead to cnt - fOff
-
- set buf to (read data from fRef ¬
- at offset fOff ¬
- using buffer size toRead)
-
- Status("Copying " & lbl & " @ " & fOff)
-
- try
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyChunk(fid, isRsrc, buf, fOff)
- set svErr to the result
- on error errStr
- ShowError(errStr)
- close fork fRef
- display progress pg with disposal
- return -5
- end try
-
- if (svErr is not 0) then
- close fork fRef
- ShowError("Server Error: " & svErr)
- display progress pg with disposal
- return -6
- end if
-
- set fOff to fOff + toRead
-
- display progress pg ¬
- value (fOff + fLast)
- end repeat
-
- close fork fRef
- set fLast to fOff
- end if
- end repeat
-
- display progress pg ¬
- labeled "Finishing…"
-
- try
- with timeout of 300 seconds
- tell application gcnServProc ¬
- of machine gcnServMach ¬
- of zone gcnServZone ¬
- to CopyEnd(fid, 0)
- end timeout
- set svErr to the result
- on error errStr
- ShowError(errStr)
- display progress pg with disposal
- return -7
- end try
-
- if (svErr is not 0) then
- beep
- ShowError("Server Error: " & svErr)
- display progress pg with disposal
- return -8
- end if
-
- if (batchNum is 0) then
- display progress pg ¬
- labeled "Deleting spool file…"
- collate fsObj with the deleter
- end if
-
- display progress pg with disposal
-
- ShowReady()
-
- return 0
- end CopyOne
-
-
- on cnGetLoginUser()
- if (not gcnLink) then
- if (kcnUseDef) then
- set gcnUser to kcnDefUser
- set gcnPass to kcnDefPass
- set gcnLink to true
- else
- GetOneFriend(false)
- end if
- end if
- end cnGetLoginUser
-
-
- on GetOneFriend(override)
- set isLink to true -- Only linking in this script!
- set userMode to "linking"
- set passButtons to {"Cancel", "OK"}
- set passButton to 2
-
- if (gcnLink) then
- set defUser to gcnUser
- set defPass to gcnPass
- else
- set defUser to kcnDefUser
- set defPass to kcnDefPass
- end if
-
- set usrPwd to KeyChainLookUp(gcnServZone, gcnServMach, isLink)
-
- if (override or usrPwd is {}) then
- set chosen to display dialog ¬
- ("Enter the friendly " & userMode & ¬
- " user's name for " & ¬
- gcnServMach & " in zone " & ¬
- gcnServZone) ¬
- default answer defUser ¬
- default button 2 ¬
- with icon note
-
- if (the button returned of chosen is "OK") then
- set defUser to the text returned of chosen
- else
- return
- end if
-
- set chosen to display dialog ¬
- ("Enter the friendly " & userMode & ¬
- " user's password for " & ¬
- gcnServMach & " in zone " & ¬
- gcnServZone) ¬
- buttons passButtons ¬
- default answer defPass ¬
- default button passButton ¬
- with icon note
-
- if (the button returned of chosen is not "Cancel") then
- set defPass to the text returned of chosen
- else
- return
- end if
-
- -- Save encrypted user/pass for future access
- KeyChainSave(gcnServZone, gcnServMach, isLink, defUser, defPass, "")
- else
- set defUser to item 1 of usrPwd
- set defPass to item 2 of usrPwd
- end if
-
- set gcnLink to true
- set gcnUser to defUser
- set gcnPass to defPass
- end GetOneFriend
-
-
- on AwaitLaunch(zoneName, machName, procName)
- set n to the clock in offset form
-
- repeat while (the clock in offset form) - n < 30
- set servs to the server processes on server gcnServMach ¬
- in AppleTalk zone gcnServZone
- pause for 120
- if (servs contains procName) then return true
- end repeat
-
- return false
- end AwaitLaunch
-
-
- property kasKeyChainPassword : "PowerScript" -- Encrypt stored data with this
- property kasPrefsFileName : "PowerScript Prefs" -- File name in <Preferences>
-
- on KeyChainLookUp(zoneName, serverName, isLinking)
- set prefOwner to "πSRV"
- if (isLinking) then set prefOwner to "πLNK"
-
- try
- set myKeyData to load preference named (zoneName & ":" & serverName) ¬
- of type prefOwner in file named kasPrefsFileName
- on error
- return {}
- end try
-
- return (encrypt the data myKeyData with password kasKeyChainPassword)
- end KeyChainLookUp
-
-
- on KeyChainSave(zoneName, serverName, isLinking, usr, pwd, ntPwd)
- set myKey to encrypt the data {usr, pwd, ntPwd} with password kasKeyChainPassword
-
- set prefOwner to "πSRV"
- if (isLinking) then set prefOwner to "πLNK"
-
- save preference myKey named (zoneName & ":" & serverName) ¬
- of type prefOwner ¬
- in file named kasPrefsFileName
- end KeyChainSave
-